import getLastProto from './getLastProto';


export default function (Action, extendsObject = {}) {

    let extendsList = Action.extends;

    if (Array.isArray(extendsList)) {
        
        for(let i=0;i<extendsList.length;i++) {
            let lastProto = getLastProto(extendsList[i]);
            let p = null;

            if (extendsList[i + 1]) {
                p = new extendsList[i + 1]();
            }

            if (p) {
                Object.assign(p, extendsObject);
                Object.setPrototypeOf(lastProto.prototype, p);
            }
        }
        let topExtend = new extendsList[0]();

        Object.assign(topExtend, extendsObject);

        Object.setPrototypeOf(getLastProto(Action).prototype, topExtend);
    }

}